package backgammon;

import java.awt.Color;
import java.awt.Graphics;

/**
 * <p>Represents the home position; where you bear off into.</p>
 * @author Jacob Kwitkoski
 * @version 1.0
 */
public class HomePosition extends Position {
    
    /**
     * <p>Creates a position with the specified colour.</p>
     * @param positionColor the colour of the position
     */
    public HomePosition(final Color newColor,
                        final int   index) {
        super(newColor, index);
    }

    @Override
    public void drawPieces(Graphics g) {
        int x = drawAtX + 2;
        if(arrayIndex > 13) {
            int y = 2;
            for (Piece piece : pieces) {
                g.setColor(piece.getColor());
                g.fillRect(x, y, 46, 12);
                y += 14;
            }
        }
        else {
            int y = 486;
            for (Piece piece : pieces) {
                g.setColor(piece.getColor());
                g.fillRect(x, y, 46,12);
                y -= 14;
            }
        }
    }
}
